﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;

namespace WenSkin.Controls
{
    public class WenDataGridViewComboBoxColumn : DataGridViewColumn
    {
        public WenDataGridViewComboBoxColumn() : base(new WenDataGridViewComboBoxCell())
        {
        }

        #region 私有属性
        private ObjectCollection items;
        #endregion
        #region 公有属性
        [Category("Wen")]
        [Description("Item编辑")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        //[Editor(typeof(Design.Editor.WenDataGridViewComboBoxCollectionEditor), typeof(UITypeEditor))]
        [Editor("System.Windows.Forms.Design.StringCollectionEditor", typeof(UITypeEditor))]
        public ObjectCollection Items => items ??= new ObjectCollection();
        #endregion


        #region 子类
        public class ObjectCollection : ArrayList
        {
            public new string this[int index] { get => base[index] as string; set => base[index] = value; }
        }
        #endregion

        public override object Clone()
        {
            var col = base.Clone() as WenDataGridViewComboBoxColumn;
            col.Items.AddRange(Items.ToArray());
            return col;
        }
    }
}